home *** CD-ROM | disk | FTP | other *** search
- Path: xanth!cs.odu.edu!Amiga-Request
- From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
- Newsgroups: comp.sources.amiga
- Subject: v90i219: Decigel020 - avoid move sr,<ea> traps on mc680x0 (where 0<=x<=3), Part01/01
- Message-ID: <13144@xanth.cs.odu.edu>
- Date: 16 Jul 90 00:28:41 GMT
- Sender: tadguy@cs.odu.edu
- Reply-To: bryce@cbmvax.commodore.com (Bryce Nesbitt)
- Lines: 229
- Approved: tadguy@cs.odu.edu (Tad Guy)
- X-Mail-Submissions-To: Amiga@cs.odu.edu
- X-Post-Discussions-To: comp.sys.amiga
-
- Submitted-by: bryce@cbmvax.commodore.com (Bryce Nesbitt)
- Posting-number: Volume 90, Issue 219
- Archive-name: util/decigel020/part01
-
- [ uuencoded executable enclosed ...tad ]
-
- Decigel020 - The functionality of the famous "decigel" program, but
- working on the 68020/68030 processors.
-
- The old Decigel would correctly patch the instruction on the 68020,
- but chances are the old (bad) instruction was still in the instruction
- cache. This code flushes the cache after modifying memory.
-
- This code may not function under future revisions of the operating
- system. This code is safe on the 68000/68010/68020 and 68030.
- This code is not expected to function on the 68040.
-
- If the instruction was MOVE SR,<ea> it is converted to MOVE CCR,<ea>.
- The instruction cache is flushed, then the instruction is re-executed.
-
-
- #!/bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 1)."
- # Contents: decigel020.asm decigel020.uu
- # Wrapped by tadguy@xanth on Sun Jul 15 20:28:30 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'decigel020.asm' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'decigel020.asm'\"
- else
- echo shar: Extracting \"'decigel020.asm'\" \(3135 characters\)
- sed "s/^X//" >'decigel020.asm' <<'END_OF_FILE'
- X**
- X**
- X** Decigel020 - The functionality of the famous "decigel" program, but
- X** working on the 68020/68030 processors.
- X**
- X** The old Decigel would correctly patch the instruction on the 68020,
- X** but chances are the old (bad) instruction was still in the instruction
- X** cache. This code flushes the cache after modifying memory.
- X**
- X** This code may not function under future revisions of the operating
- X** system. This code is safe on the 68000/68010/68020 and 68030.
- X** This code is not expected to function on the 68040.
- X**
- X**
- X** Written Tuesday 03-Apr-90 21:21:47 -Bryce Nesbitt
- X**
- X**
- X INCLUDE "exec/types.i"
- X INCLUDE "exec/memory.i"
- X INCLUDE "exec/ables.i"
- X INCLUDE "exec/execbase.i"
- X INCLUDE "libraries/dosextens.i"
- X
- X INT_ABLES
- X
- X XREF _LVOFindTask
- X XREF _LVOSupervisor
- X
- XABSEXECBASE EQU 4
- XPrivTrapVector EQU $20
- X
- X
- X
- X
- X;-------------- install patch then detach -----------------------------------
- X
- X move.l ABSEXECBASE,a6
- X
- X
- X ;
- X ; Contents of the old vector are used to self-modify our
- X ; code. The new vector replaces the old.
- X ;
- X DISABLE
- X move.l PrivTrapVector,ModifyCode+2
- X bsr.s FlushCache
- X move.l #NewPrivTrap,PrivTrapVector
- X ENABLE
- X
- X
- X ;
- X ; Detach our code from the CLI
- X ;
- X suba.l a1,a1
- X jsr _LVOFindTask(a6)
- X move.l d0,a0
- X move.l pr_CLI(a0),a0
- X add.l a0,a0
- X add.l a0,a0
- X move.l a0,d0
- X beq.s not_cli
- X clr.l cli_Module(a0)
- Xnot_cli: moveq #0,d0
- X rts
- X
- X
- X
- X
- X*
- X* Flush the instruction cache
- X*
- XFlushCache: movem.l a5/a6,-(sp)
- X move.l ABSEXECBASE,a6
- X btst.b #AFB_68020,AttnFlags+1(a6) ;>=68020 includes cache
- X beq.s fc_nocache
- X
- X lea.l FlushTrap(pc),a5
- X jsr _LVOSupervisor(a6)
- X
- Xfc_nocache: movem.l (sp)+,a5/a6
- X rts
- X;
- X;
- XFlushTrap: dc.w $4e7a,$0002 ;movec.l CACR,d0
- X bset #3,d0 ;Set "Clear instruction cache" bit
- X dc.w $4e7b,$0002 ;movec.l d0,CACR
- X rte
- X
- X
- X
- X
- X
- X*****************************************************************************
- X** **
- X** **
- X** The trap handler wedged into the privilege violation vector. **
- X** **
- X** If the instruction was MOVE SR,<ea> it is converted to MOVE CCR,<ea>. **
- X** The instruction cache is flushed, then the instruction is re-executed. **
- X** **
- X** **
- X*****************************************************************************
- X
- XSTKOFFSET EQU 4*3
- X
- X;
- X; New privilege violation vector
- X;
- XNewPrivTrap: movem.l d0/a0/a6,-(sp)
- X move.l STKOFFSET+2(sp),a0
- X move.w (a0),d0 ; Examine opcode
- X andi.w #~%111111,d0 ; Mask out EA field
- X cmpi.w #$40C0,d0 ; A MOVE SR,<ea>?
- X beq.s GotOne
- X movem.l (sp)+,d0/a0/a6
- XModifyCode: jmp $01234567 ; To previous handler... (exit)
- X
- X;
- X; Code executed if the instruction was MOVE SR,<ea>
- X;
- XGotOne: move.l ABSEXECBASE,a6
- X
- X
- X DISABLE
- X bset #1,(a0) ; Convert to MOVE CCR,<ea>
- X btst.b #AFB_68020,AttnFlags+1(a6) ;>=68020 includes cache
- X beq.s no_cache
- X
- X dc.w $4e7b,$8802 ; movec.l a0,CAAR
- X dc.w $4e7a,$0002 ; movec.l CACR,d0
- X bset #2,d0 ; Set "Clear entry in instruction cache"
- X dc.w $4e7b,$0002 ; movec.l d0,CACR
- Xno_cache: ENABLE
- X
- X
- X movem.l (sp)+,d0/a0/a6
- X rte ; Rerun new opcode... (exit)
- X
- X END
- END_OF_FILE
- if test 3135 -ne `wc -c <'decigel020.asm'`; then
- echo shar: \"'decigel020.asm'\" unpacked with wrong size!
- fi
- # end of 'decigel020.asm'
- fi
- if test -f 'decigel020.uu' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'decigel020.uu'\"
- else
- echo shar: Extracting \"'decigel020.uu'\" \(745 characters\)
- sed "s/^X//" >'decigel020.uu' <<'END_OF_FILE'
- Xbegin 644 decigel020
- XM```#\P`````````#``````````(````V``````````````/I````-BQX``0SN
- XM_$```-_PFE(N`28C^``@````DF$R(?P```!X`"!3+@$F;`@S_,```-_PFI/)Q
- XM3J[^VB!`(&@`K-'(T<@@"&<$0J@`/'``3G5(YP`&+'@`!`@N``$!*6<(2_H`X
- XM#$ZN_^),WV``3G5.>@`"",```TY[``).<TCG@((@;P`.,!`"0/_`#$!`P&<*D
- XM3-]!`4[Y`2-%9RQX``0S_$```-_PFE(N`28(T``!""X``0$I9Q!.>X@"3GH`W
- XM`@C```).>P`"4RX!)FP(,_S```#?\)I,WT$!3G,``````^P````"````````J
- XM`!0````<`````````_`````#14Y!0DQ%+C`U-@``````T`````-%3D%"3$4N^
- XM,#4U```````P`````TUO9&EF>4-O9&4``````)`````#3F5W4')I=E1R87``E
- XM````>`````-F8U]N;V-A8VAE``````!D`````T9L=7-H0V%C:&4``````$P`]
- XM```";F]?8V%C:&4```#"`````D=O=$]N90``````E@````-&;'5S:%1R87``T
- XM``````!J`````FYO=%]C;&D`````2`````````/R```#Z0````````/R```#U
- X)Z@````````/R?
- X``
- Xend
- Xsize 504
- END_OF_FILE
- if test 745 -ne `wc -c <'decigel020.uu'`; then
- echo shar: \"'decigel020.uu'\" unpacked with wrong size!
- fi
- # end of 'decigel020.uu'
- fi
- echo shar: End of archive 1 \(of 1\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have the archive.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
- Mail comments to the moderator at <amiga-request@cs.odu.edu>.
- Post requests for sources, and general discussion to comp.sys.amiga.
-